package com.swak.persistence.mybatis.methods.impls;

import com.swak.persistence.mybatis.methods.AbstractMethod;
import com.swak.persistence.mybatis.methods.Sqls;

/**
 * 条件查询
 * 
 * @author lifeng
 * @date 2021年1月25日 下午5:13:45
 */
public class QueryByCondition extends AbstractMethod {

	@Override
	protected void doInject() {
		if (!this.supportMethod(Sqls.QUERY_BY_CONDITION)) {
			return;
		}
		
		String sql = new StringBuilder().append(SCRIPT_START).append(SELECT).append(SPACE)
				.append(this.parseSqlColumns()).append(SPACE).append(FROM).append(SPACE).append(this.table.getName())
				.append(SPACE).append(this.parseWhereLogicDelEqualColumn(false))
				.append(QueryByCondition.includeConditionClause()).append(QueryByCondition.includeOrderClause())
				.append(SCRIPT_END).toString();

		this.addSelectMappedStatement(Sqls.QUERY_BY_CONDITION.getMethod(), sql);
	}
}
